<template>
  <view class="page">
    <view :style="{ height: statusBarHeight + 'px' }"></view>
    <view class="nav-bar"
      ><view class="nav-left" @tap="goBack">
        <text class="icon fa fa-arrow-left fa-gray"></text> </view
      ><view class="nav-title">考试成绩</view
      ><text class="nav-action" @tap="exportData">导出</text></view
    >
    <scroll-view scroll-y class="content">
      <view class="stats-grid"
        ><view class="stat-box"
          ><text class="stat-label">平均分</text
          ><text class="stat-value">82.6</text></view
        ><view class="stat-box"
          ><text class="stat-label">通过率</text
          ><text class="stat-value">76%</text></view
        ><view class="stat-box"
          ><text class="stat-label">排名</text
          ><text class="stat-value">前 15%</text></view
        ></view
      >
      <view class="section"
        ><text class="section-title">近期成绩</text
        ><view class="score-list"
          ><view class="score-item"
            ><view class="score-info"
              ><text class="score-name">内科住培 · 阶段考试</text
              ><text class="score-time"
                >提交：2025-09-12 · 时长 48:12</text
              ></view
            ><view class="score-result"
              ><text class="score-num">86</text
              ><text class="score-status">通过</text></view
            ></view
          ><view class="score-item"
            ><view class="score-info"
              ><text class="score-name">CTA临床思维测评</text
              ><text class="score-time"
                >提交：2025-08-28 · 时长 28:10</text
              ></view
            ><view class="score-result"
              ><text class="score-num">78</text
              ><text class="score-status">通过</text></view
            ></view
          ></view
        ></view
      >
      <view class="section"
        ><view class="section-header"
          ><text class="section-title">错题本</text
          ><text class="section-link" @tap="goToMistakes">查看全部</text></view
        ><view class="mistake-list"
          ><view class="mistake-item"
            ><text class="mistake-question">单选题：脓毒症临床表现</text
            ><text class="mistake-answer"
              >正确答案：C · 解析：脓毒症常见呼吸急促，降低不典型。</text
            ></view
          ><view class="mistake-item"
            ><text class="mistake-question">多选题：ARDS诊断标准</text
            ><text class="mistake-answer"
              >正确答案：A/B/D · 解析：根据柏林定义…</text
            ></view
          ></view
        ></view
      >
    </scroll-view>
  </view>
</template>
<script>
export default {
  data() {
    return { statusBarHeight: 0 };
  },
  onLoad() {
    this.statusBarHeight = uni.getSystemInfoSync().statusBarHeight || 0;
  },
  methods: {
    goBack() {
      uni.navigateBack();
    },
    exportData() {
      uni.showToast({ title: "导出功能开发中", icon: "none" });
    },
    goToMistakes() {
      uni.navigateTo({ url: "/pages/mistakes/mistakes" });
    },
  },
};
</script>
<style scoped>
.page {
  min-height: 100vh;
  background: #fff;
  display: flex;
  flex-direction: column;
}
.nav-left {
  position: absolute;
  left: 16px;
  top: 50%;
  transform: translateY(-50%);
}
.nav-bar {
  height: 44px;
  background: #fff;
  border-bottom: 1px solid #f0f0f0;
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
}
.nav-title {
  font-size: 17px;
  font-weight: 600;
}
.nav-action {
  position: absolute;
  right: 16px;
  font-size: 14px;
  color: #6b7280;
}
.content {
  flex: 1;
  padding: 0 16px;
  box-sizing: border-box;
}
.stats-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
  margin-top: 12px;
}
.stat-box {
  background: #f9fafb;
  border-radius: 12px;
  padding: 12px;
  text-align: center;
}
.stat-label {
  display: block;
  font-size: 12px;
  color: #6b7280;
  margin-bottom: 4px;
}
.stat-value {
  display: block;
  font-size: 18px;
  font-weight: 600;
  color: #111;
}
.section {
  margin-top: 16px;
}
.section-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 8px;
}
.section-title {
  font-size: 15px;
  font-weight: 600;
  color: #111;
  margin-bottom: 8px;
}
.section-link {
  font-size: 12px;
  color: #6b7280;
}
.score-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.score-item {
  background: #fff;
  border: 1px solid #f3f4f6;
  border-radius: 12px;
  padding: 12px;
  display: flex;
  justify-content: space-between;
}
.score-info {
  flex: 1;
}
.score-name {
  display: block;
  font-size: 14px;
  font-weight: 500;
  color: #111;
  margin-bottom: 4px;
}
.score-time {
  display: block;
  font-size: 12px;
  color: #6b7280;
}
.score-result {
  text-align: right;
}
.score-num {
  display: block;
  font-size: 18px;
  font-weight: 600;
  color: #059669;
  margin-bottom: 2px;
}
.score-status {
  display: block;
  font-size: 12px;
  color: #6b7280;
}
.mistake-list {
  background: #f9fafb;
  border-radius: 16px;
  overflow: hidden;
}
.mistake-item {
  padding: 12px;
  border-bottom: 1px solid #e5e7eb;
}
.mistake-item:last-child {
  border-bottom: none;
}
.mistake-question {
  display: block;
  font-size: 14px;
  color: #4b5563;
  margin-bottom: 4px;
}
.mistake-answer {
  display: block;
  font-size: 12px;
  color: #059669;
  line-height: 1.5;
}
</style>

